//
//  chooseBtnView.m
//  AnnCar_user
//
//  Created by LiBenCan on 17/10/24.
//  Copyright © 2017年 LiBenCan. All rights reserved.
//

#import "chooseBtnView.h"
@interface chooseBtnView()
{
    NSString *chooseImageStr;
    NSString *unChooseImageStr;
}
@end
@implementation chooseBtnView

-(instancetype)initWithFrame:(CGRect)frame Title:(NSString *)title NomolImageV:(NSString *)nomalImageStr SelectImageV:(NSString *)selectImageStr IsSelect:(BOOL)isSelect
{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        self.userInteractionEnabled = YES;
        
        if (!_titleLab) {
            
            chooseImageStr = selectImageStr;
            unChooseImageStr = nomalImageStr;
            float titleWidth = [ToolViewVC getlabWidth:title WithFont:14*screenW_6];

            //左边图片
            _leftImagV = [UIImageView new];
            _leftImagV.image = [UIImage imageNamed:nomalImageStr];
            _leftImagV.frame = CGRectMake(frame.size.width/2-_leftImagV.image.size.width/2-titleWidth/2-10*screenW_6,frame.size.height/2-_leftImagV.image.size.height/2,_leftImagV.image.size.height,_leftImagV.image.size.height);
            [self addSubview:_leftImagV];
        
            
            //按钮标题

            _titleLab = [TomamaUI createLabel:CGRectMake(CGRectGetMaxX(_leftImagV.frame)+10*screenW_6,frame.size.height/2-10*screenW_6,titleWidth+20*screenW_6, 20*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:14*screenW_6] textColor:TextBlack text:@""];
            [self addSubview:_titleLab];
        
        }
        _leftImagV.image = [UIImage imageNamed:isSelect?selectImageStr:nomalImageStr];
        _titleLab.text = title;
        
    }
    return self;
}
-(void)IsChoose:(BOOL)isChoose
{
     _leftImagV.image = [UIImage imageNamed:isChoose?chooseImageStr:unChooseImageStr];
}
@end
